<?php


namespace App\Models;


use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Support\Collection;

/**
 * Class Express
 * @package App\Models
 * @property Collection blacklist
 */
class Express extends Model
{
    protected $table = 'express';
    protected $fillable = ['code', 'name', 'customs_code', 'customs_name', 'insured', 'phone', 'contacts', 'remark'];

    protected static function boot()
    {
        static::addGlobalScope('orderBy', function (Builder $query) {
            $query->orderByDesc('id');
        });
        parent::boot();
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\HasMany
     * @author luffyzhao@vip.126.com
     */
    public function blacklist()
    {
        return $this->hasMany(ExpressBlacklist::class, 'express_id');
    }
}
